package com.example.mytayunapi.Controller;

import com.example.mytayunapi.Entity.adminInfo;
import com.example.mytayunapi.Entity.collectInfo;
import com.example.mytayunapi.Service.collectInfoService;
import com.example.mytayunapi.Vo.CollectandProducts;
import com.example.mytayunapi.Vo.VCollectResp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("collect")
public class collectController {
    @Autowired
    private collectInfoService collecctService;

    //http://localhost:8080/collect/addToWishlist
    @PostMapping("/addToWishlist")
    public Integer addToWishlist(@RequestBody VCollectResp collectInfo) {
        Integer i =  collecctService.insertcollectInfo(collectInfo);
        return i;
    }

    //http://localhost:8080/collect/getProductCollectInfo
    @GetMapping("/getProductCollectInfo")
    public List<CollectandProducts> getProductCollectInfo(@RequestParam String schoolDegree) {
        return collecctService.getProductCollectInfo(schoolDegree);
    }

    //http://localhost:8080/collect/removeProductCollect
    @DeleteMapping("/removeProductCollect")
    public Integer removeProductCollect(@RequestParam("schoolDegree") String schoolDegree,
                                        @RequestParam("productId") Long productId) {
        return collecctService.deleteProductCollect(schoolDegree, productId);
    }

}
